package cn.edu.ctbu.datajpa01.repository;

import cn.edu.ctbu.datajpa01.domain.Student;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface StudentRepository extends JpaRepository<Student,Integer> {

    /**
     * 按名字查询
     * @param name
     * @return
     */

    List<Student> findByNameLike(String name);

    /**
     * 按名字和密码查询
     * @param name
     * @param password
     * @return
     */
    List<Student> findByNameAndPassword(String name,String password);

    @Query(nativeQuery = false,value = "FROM  tb_student o where o.no=(select max(t.no) from tb_student t)")
    Student getTheMaxNo();
}
